package com.godpaper.the2tigers.busniess.managers
{
	import flash.display.DisplayObject;
	
	import mx.core.Application;
	import mx.core.IFlexDisplayObject;
	import mx.managers.CursorManager;
	import mx.managers.PopUpManager;
	import com.godpaper.the2tigers.views.components.ThinkingProgressBar;
	
	
	public  class ProgressBarManager
	{
//		private static var iCustomProgressBarModule:ICustomProgressBarModule;	
		private static var customProgressBarModule:IFlexDisplayObject;
		
		// Singleton instance of ProgressBarManager
		private static var instance:ProgressBarManager;
		
		public function ProgressBarManager(access:Private)
		{
			if (access != null){
				if (instance == null)
				{				
					instance = this;
				}
			}
			else{
				throw new Error( "ProgressBarManager.SINGLETON_EXCEPTION", "@ProgressBarManager" );
			}
		}
		
		public function showProgressBar():void
		{
			customProgressBarModule = 
				PopUpManager.createPopUp(Application.application as DisplayObject,ThinkingProgressBar,true,null);
			PopUpManager.centerPopUp(customProgressBarModule);
			CursorManager.setBusyCursor();
		}
		public function removeProgressBar():void
		{			
			if(customProgressBarModule)
			{
				PopUpManager.removePopUp(customProgressBarModule);
				customProgressBarModule = null;

				mx.managers.CursorManager.removeAllCursors();
				
			}
			else
			{
				//Alert.show("progressBarIsNotReadyToRemove!","Fatal Error!");
			}	
			
		}
		
		/**
		 * 
		 * @return the Singleton instance of ProgressBarManager
		 * 
		 */		
		public static function getInstance():ProgressBarManager
		{
			if(instance == null)
			{
				instance = new ProgressBarManager(new Private());
			}
			return instance;
		}
	}

}
/**
 * Inner class which restricts contructor access to Private
 */
class Private 
{
	
}